import Vue from 'vue';
// 引入路由器
import VueRouter from 'vue-router';
// 引入路由
import HomePage from '../views/HomePage.vue';
import CatePage from '../views/CatePage.vue';
import CartPage from '../views/CartPage.vue';
import PersonalPage from '../views/PersonalPage.vue';
import ShengXian from '../views/homepage/ShengXian.vue';
import TiaoLiao from '../views/homepage/TiaoLiao.vue';
import ShengRou from '../views/homepage/shengxian/ShengRou.vue'
import DanLei from '../views/homepage/shengxian/DanLei.vue';
import NotFound from '../views/NotFound.vue';



// 声明使用vue插件

Vue.use(VueRouter);

const router = new VueRouter({
    mode:"hash",
    // 注册路由
    routes:[
        {
            path:'/homepage',//此处/代表根路径  路径当中不建议有中文
            name:'homepage',
            component:HomePage,
            children:[
                {
                    path:'shengxian',
                    name:'shengxian',
                    component:ShengXian,
                    children:[
                        {
                            path:'shengrou',//可以省略父级的路径，直接写当前的，但是不能在前面加 / 
                            name:'shengrou',
                            component:ShengRou
                        },
                        {
                            path:'/homepage/shengxian/danlei',
                            name:'danlei',
                            component:DanLei
                        }
                    ]
                },{
                    path:'/homepage/tiaoliao',
                    name:'tiaoliao',
                    component:TiaoLiao
                }
            ]
        },
        {
            path:'/catepage',
            name:'catepage',
            component:CatePage
        },
        {
            path:"/cartpage",
            name:'cartpage',
            component:CartPage
        },
        {
            path:'/personalpage',
            name:'personalpage',
            component:PersonalPage
        },
        // 重定向
        {
            path:'/',
            redirect:'/homepage'
        },
        // *所有不存在
        {
            path:'*',
            component:NotFound
        }
    ]
})

export default router